package com.grj.park.boot.domain;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Size;

/**
 * @TableName permission
 */
@TableName(value = "permission")
@Data
@ApiModel(description = "权限实体类")
public class Permission implements Serializable{

    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "权限ID", example = "1")
    private Long permissionId;

    @Size(min = 1, max = 100, message = "权限名称长度必须为1到100个字符")
    @ApiModelProperty(value = "权限名称", example = "用户管理", required = true)
    private String permissionName;

    @ApiModelProperty(value = "图标", example = "user")
    private String icon;

    @ApiModelProperty(value = "排序顺序", example = "1")
    private Integer sortOrder;

    @Size(min = 1, max = 100, message = "权限代码长度必须为1到100个字符")
    @ApiModelProperty(value = "权限代码", example = "user:manage", required = true)
    private String permissionCode;

    @Size(min = 1, max = 100, message = "权限类型长度必须为1到100个字符")
    @ApiModelProperty(value = "权限类型", example = "menu", required = true)
    private String permissionType;

    @ApiModelProperty(value = "路径", example = "/user/manage")
    private String path;

    @ApiModelProperty(value = "父级字典ID", example = "1")
    @TableField(value = "parent_id")
    private Long parentId;

    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(value = "状态", example = "normal")
    private String status;

    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间", example = "2023-10-01 12:00:00")
    private Date createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "更新时间", example = "2023-10-01 12:00:00")
    private Date updateTime;

    @TableField(fill = FieldFill.INSERT)
    @ApiModelProperty(value = "创建用户ID", example = "1")
    private Long createUser;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(value = "更新用户ID", example = "1")
    private Long updateUser;

    @ApiModelProperty(value = "逻辑删除标志", example = "0")
    private Integer deleted;

    @TableField(exist = false)
    private List<Permission> children;

//    @TableField(exist = false)
//    private Boolean hasChildren;

}
